package com.wkk.nursinghome.dao;

import com.wkk.nursinghome.domain.Withdrawal;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IWithdrawalDao {
    //根据编号查询所要退住人信息
    @Select("select * from withdrawal where id=#{id}")
    public Withdrawal selectById(Integer id);

    //查询所有所登记人信息
    @Select("select * from withdrawal order by id asc")
    public List<Withdrawal> selectAll();

    //添加登记人信息
    @Insert("insert into withdrawal (name, sex,age,fnumber,citime,withdrawaltime,withdrawatype,withdrawareason,status,apptime,auditopinion,reviewer,reviewtime,remarks) " +
            "values (#{name}, #{sex},#{age}, #{fnumber},#{citime}, #{withdrawaltime},#{withdrawatype}, #{withdrawareason},#{status}, #{apptime},#{auditopinion}, #{reviewer},#{reviewtime},#{remarks})")
    @SelectKey(statement = "select LAST_INSERT_ID()",keyProperty = "id",before = false,resultType = Integer.class)
    public int insertWithdrawal(Withdrawal withdrawal);

    //删除所登记人信息
    @Delete("delete from withdrawal where id=#{id}")
    public int deleteWithdrawalById(Integer id);

    //修改所登记人信息
    @UpdateProvider(type = WithdrawalSQLProvider.class,method = "updateWithdrawal")
    public int updateWithdrawal(Withdrawal withdrawal);

    //根据条件查询所登记人信息
    @SelectProvider(type = WithdrawalSQLProvider.class,method = "selectWithdrawalByCondition")
    public List<Withdrawal> getWithdrawalByCondition(Withdrawal withdrawal);
}
